#include "base_thread.h"

using namespace std;
using namespace boost::asio;

base_thread::base_thread()
{
}

void base_thread::run()
{
    ptr_io_context_ = make_shared<io_context>();
    ptr_work_ = make_shared<io_context::work>(*ptr_io_context_);
    auto self = shared_from_this();
    thread_handle_ = thread([self]() 
        {
            self->ptr_io_context_->run();
        });
    thread_handle_.detach();
}

std::shared_ptr<boost::asio::io_context> base_thread::get_io_context()
{
    return ptr_io_context_;
}
